package sharewithus.business.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import sharewithus.business.dao.IRelationShipDAO;
import sharewithus.business.service.IRelationShipService;

/** 
 * @ClassName: RelationShipServiceImpl 
 * @Description: 
 * @author chenyun
 * @date 2012-5-16 上午11:37:07 
 */
public class RelationShipServiceImpl implements IRelationShipService {
	
	@Autowired
	@Qualifier("relationDAO")
	private IRelationShipDAO rsDao;
	
	public void addAttention(String uid, String follower) throws Exception {
		rsDao.addRelationShipInCache(uid, follower);
		rsDao.putAddRSMsg2Queue(uid, follower);
	}

	public void cancelAttention(String uid, String follower) throws Exception {
		rsDao.removeRelationShipInCache(uid, follower);
		rsDao.putRemoveRSMsg2Queue(uid, follower);
	}

	public List<String> getFans(String uid) throws Exception {
		return rsDao.getFansFromCache(uid);
	}
	
	public List<String> getFollowers(String uid) throws Exception {
		return rsDao.getFollwersFromCache(uid);
	}

	public List<String> getFansByPage(String uid, long start, long limit)
			throws Exception {
		
		long startIndex = (start-1) * limit;
		long endIndex = start * limit - 1;
		
		return rsDao.getFansFromCache(uid, startIndex, endIndex);
	}

	public List<String> getFollwersByPage(String uid, long start, long limit)
			throws Exception {
		long startIndex = (start-1) * limit;
		long endIndex = start * limit - 1;
		
		return rsDao.getFollwersFromCache(uid, startIndex, endIndex);
	}

	public long getFansNum(String uid) throws Exception {
		return rsDao.getFansNum(uid);
	}

	public long getFollowerNum(String uid) throws Exception {
		return rsDao.getFollwerNum(uid);
	}

}

